var ctx = $("#ctx").html();
var layer;

$(function() {
	layui.use(['layer'], function(){
		layer = layui.layer;
	});
})
/**
 * 验证邮箱地址是否正确
 * @param email
 * @returns
 */
function validEmail(email) {
	if(email) {
		var reg = /^[A-Za-z0-9\u4e00-\u9fa5]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/;
		return reg.test(email + "");
	}
	return false;
}

/**
 * 弹出对话框
 * @param msg
 * @param icon
 * @returns
 */
function layAlert(msg, icon) {
	layer.alert(msg, {
		icon: icon,
		skin: 'layer-ext-moon'
	});
}

/**
 * 弹出成功的提示框
 * @param msg
 * @returns
 */
function layAlertSuccess(msg) {
	layAlert(msg, 6);
}

/**
 * 弹出失败的提示框
 * @param msg
 * @returns
 */
function layAlertFailed(msg) {
	layAlert(msg, 5);
}

/**
 * 加载框
 * @returns
 */
function layLoading() {
	var index = layer.load(3, {
		  shade: [0.1, '#fff'] //0.1透明度的白色背景
	});
	return index;
}

function layOpen(type, title, content) {
	layer.open({
		type: type,
		title: title,
		shadeClose: true,
		shade: false,
		maxmin: true, //开启最大化最小化按钮
		area: ['800px', '600px'],
		content: content
    });
}
function layOpenFromContent(title, content) {
	layOpen(1, title, content);
}
function layOpenFromUrl(title, url) {
	layOpen(2, title, url);
}